package com.hex.ds.hdtp.core.app.script.transfer.converter;

import com.hex.ds.hdtp.core.app.common.enums.BasicListStatus;
import com.hex.ds.hdtp.core.app.common.util.FileUtil;
import com.hex.ds.hdtp.core.app.script.transfer.dto.request.ScriptConvertSourceListRequestDto;
import com.hex.ds.hdtp.core.app.script.transfer.dto.request.ScriptConvertTaskRequestDto;
import com.hex.ds.hdtp.core.app.script.transfer.dto.response.ScriptConvertTaskResponseDto;
import com.hex.ds.hdtp.core.inf.script.transfer.po.ScriptConvertTaskPo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.io.File;
import java.util.List;

/**
 * @Package: com.hex.ds.hdtp.core.app.transfer.script.converter
 * @ClassName IScriptConvertTaskConverter
 * @Description: 脚本转换任务DTO对象与PO对象转换器
 * @Author: wz.li
 * @Date 2023/2/12 10:40
 * @Version v2.0.2
 **/
@Mapper(componentModel = "spring", imports = {BasicListStatus.class, FileUtil.class})
public interface IScriptConvertTaskConverter {

    ScriptConvertTaskPo toScriptConvertTaskPo(ScriptConvertTaskRequestDto scriptConvertTaskRequestDto);

    ScriptConvertTaskResponseDto toScriptConvertTaskResponseDto(ScriptConvertTaskPo scriptConvertTaskPo);

    List<ScriptConvertTaskResponseDto> toScriptConvertTaskResponseDtoList(List<ScriptConvertTaskPo> scriptConvertTaskPos);

    @Mapping(target = "pkId", ignore = true)
    @Mapping(target = "convertTaskPkId", source = "scriptConvertTaskPo.pkId")
    @Mapping(target = "convertFilePath", source = "scriptConvertTaskPo.convertFilePath")
    @Mapping(target = "sourceFilePath", source = "file.parent")
    @Mapping(target = "sourceFileName", source = "file.name")
    @Mapping(target = "status", expression = "java(BasicListStatus.TODO.name())")
    ScriptConvertSourceListRequestDto toScriptConvertListRequestDto(ScriptConvertTaskPo scriptConvertTaskPo, File file);

}
